//
//  ProfileInputView.m
//  Cat
//
//  Created by lushitong on 2019/1/2.
//  Copyright © 2019年 lushitong. All rights reserved.
//

#import "ProfileInputView.h"

@interface ProfileInputView()<UITextFieldDelegate>

@property (nonatomic, strong) UIView *topLineView;
@property (nonatomic, strong) UIView *bottomLineView;

@property (nonatomic, assign) BOOL didSetupConstraints;


@end
@implementation ProfileInputView


#pragma mark - Pub

- (QKTextField *)textField {
	if (!_textField) {
		_textField = [[QKTextField alloc] init];
		_textField.font = [UIFont fontWith3x:52.0];
	}
	return _textField;
}

#pragma mark - Override

- (instancetype)initWithFrame:(CGRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		self.backgroundColor = [UIColor whiteColor];
		
		[self loadSubviews];
	}
	return self;
}

- (void)updateConstraints {
	[super updateConstraints];
	
	if (!self.didSetupConstraints) {
		NSArray *lineViewList = @[self.topLineView, self.bottomLineView];
		[lineViewList autoSetViewsDimension:ALDimensionHeight toSize:0.5];
		[lineViewList autoMatchViewsDimension:ALDimensionWidth];
		
		[self.topLineView autoPinEdgeToSuperviewEdge:ALEdgeTop];
		[self.topLineView autoPinEdgeToSuperviewEdge:ALEdgeLeft];
		[self.topLineView autoPinEdgeToSuperviewEdge:ALEdgeRight];
		
		[self.bottomLineView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
		
		[self.textField autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.topLineView];
		[self.textField autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.bottomLineView];
		[self.textField autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:10.0];
		[self.textField autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:10.0];
		
		self.didSetupConstraints = YES;
	}
}

#pragma mark - Pri Method

- (void)loadSubviews {
	[self addSubview:self.topLineView];
	[self addSubview:self.bottomLineView];
	[self addSubview:self.textField];
}

- (UIView *)createLine {
	UIView *sepLineView = [UIView new];
	sepLineView.backgroundColor = [UIColor qkSepLineColor];
	return sepLineView;
}

#pragma mark - Pri Property

- (UIView *)topLineView {
	if (!_topLineView) {
		_topLineView = [self createLine];
	}
	return _topLineView;
}

- (UIView *)bottomLineView {
	if (!_bottomLineView) {
		_bottomLineView = [self createLine];
	}
	return _bottomLineView;
}

@end
